// https://leetcode.cn/problems/calculate-digit-sum-of-a-string/description/

import "strconv"
import "fmt"
func digitSum(s string, k int) string {
    for len(s) > k {
		sb := ""
		for i := 0; i < len(s); i += k {
			t := s[i:min(i + k, len(s))]
			a := 0
			for _, v := range t {
				iv, _ := strconv.Atoi(string(v))
                a += iv
			}
			sb += strconv.Itoa(a)
		}
		s = sb
	}
	return s
}